<?php if(!defined('HDPHP_PATH'))exit;C('SHOW_NOTICE',FALSE);?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>无标题文档</title>
		<link href="http://127.0.0.1/vancl_php/Application/Admin/View/css/style1.css" rel="stylesheet" type="text/css" />
		<link rel="stylesheet" href="http://127.0.0.1/vancl_php/Static/css/hdjs.css" />
		<script src="http://127.0.0.1/vancl_php/Static/js/jquery-1.7.2.min.js"></script>
		<script src="http://127.0.0.1/vancl_php/Static/js/hdjs.min.js"></script>

		<style>
			.hd-page span{
				
				color:black !important;
			}
			span{
				display: inline;
			}
		</style>
		<script type="text/javascript">
			function delMsg(id) {
			        hd_modal({
			            width: 400,//宽度
			            height: 200,//高度
			            title: '提示',//标题
			            content: '您要删除这个提问吗?',//提示信息
			            button: true,//显示按钮
			            button_success: "确定",//确定按钮文字
			            button_cancel: "关闭",//关闭按钮文字
			            timeout: 0,//自动关闭时间 0：不自动关闭
			            shade: false,//背景遮罩
			            shadeOpacity: 0.9,//背景透明度
			            success: function () {//点击确定后的事件
							location.href="http://127.0.0.1/vancl_php/index.php/Admin/Quest/delQuest/qid/"+id;
			            },
			            cancel: function () {//点击关闭后的事件
			
			            }
			        });
			    }
		</script>

		</script>

	</head>

	<body>

		<div class="place">
			<span>位置：</span>
			<ul class="placeul">
				<li><a href="#">首页</a>
				</li>
				<li><a href="#">提问管理</a>
				</li>
				<li><a href="#">问题列表</a>
				</li>
			</ul>
		</div>

		<div class="rightinfo">

			<div class="tools">

				<ul class="toolbar">
					<li class="click"><a href="<?php echo U('Quest/index',array('status'=>2));?>"><span></span>已回复</a>
					</li>
					<li class="click"><span></span><a href="<?php echo U('Quest/index',array('status'=>1));?>">未回复</a>
					</li>
					<li class="click"><span></span><a href="<?php echo U('Quest/index');?>">全部</a>
					</li>

				</ul>

				<ul class="toolbar1">
					<!--<li><span><img src="http://127.0.0.1/vancl_php/Application/Admin/View/images/t05.png" /></span>设置</li>-->
				</ul>

			</div>

			<table class="tablelist">
				<thead>
					<tr>
						<th>问题ID</th>
						<th>咨询商品</th>
						<th>用户名</th>
						<th>提问内容</th>
						<th>提问时间</th>
						<th>回复内容</th>
						<th>操作</th>
					</tr>
				</thead>
				<tbody>
					<?php foreach ($quests as $key=>$value){?>
						<tr>
							<td><?php echo $value['qid'];?></td>
							<td><a href="<?php echo U('Index/Details/index',array('gid'=>$value['gid']));?>"><?php echo $value['goods_name'];?></a>
							</td>
							<td><?php echo $value['username'];?></td>
							<td class="qcontent"><?php echo $value['quest_content'];?></td>
							<td><?php echo date('Y-m-d H:i:s',$value['quest_time']);?></td>
							<td class="answers"><?php echo $value['answer'];?></td>

							<td>
								    <?php if(!$value['answer']){ ?>
									<a href="javascript:;" class="hd-btn hd-btn-info reply" qid="<?php echo $value['qid'];?>" style="display:inline">回复</a>
								<?php } ?>
								<a href="javascript:delMsg(<?php echo $value['qid'];?>)" class="hd-btn-danger hd-btn" style="display:inline">删除</a>
							</td>
						</tr>
					<?php }?>
				</tbody>
			</table>
			<div id="reply" style="display:none;">
				<div class="formbody">

					<div class="formtitle"><span>回复</span>
					</div>

					<ul class="forminfo">
						<li>
							<label>提问内容:</label><span id="qqcontent" style="line-height: 33px;"></span>
						</li>
						<form action="javascript:;" method="post" id="replyid">
							<input type="hidden" name="qid" />
							<li>
								<label>回复:</label>
								<textarea name="answer" cols="" rows="" class="textinput" placeholder="请输入回复内容"></textarea>
							</li>
							<li>
								<label>&nbsp;</label>
								<input id="replybtn" type="submit" class="btn" value="回复" />
							</li>
						</form>
					</ul>

				</div>
			</div>
			<div class="hd-page">
				<?php echo $page;?>
			</div>
		</div>
		<script type="text/javascript">
			//当点击回复时拿到当前的问题ID
			    $('.reply').click(function(){
			    	var qid = $(this).attr('qid');
			    	//将Qid放入隐藏表单name=qid中
			    	$('#reply').show();
			    	$('input[name=qid]').val(qid);
			    	//再将问题抓取到放在提问内容表单中
			    	var text = $(this).parent().siblings('.qcontent').text();
			    	$('#qqcontent').html(text);
			    	
			    })
			    $('#replybtn').click(function(){
			    	var $parents = $('#reply');
			    	var data = $("#replyid").serialize();	
			    		$.ajax({
				    		url:"<?php echo U('addAnswer');?>",
				    		data:data,
				    		dataType:'json',
				    		type:'post',
			    			success:function(phpData){
			    				if(phpData.status==1){
			    					//隐藏回复表单
			    					$parents.fadeOut();
			    					hd_alert({
			    						message:phpData.message,
			    						timeout:3
			    					})
			    					$('.reply[qid='+phpData.data.qid+']').parent().prev().html(phpData.data.answer);
			    					$('.reply[qid='+phpData.data.qid+']').remove();
			    				}else{
			    					hd_alert({
			    						message:phpData.message,
			    						timeout:3
			    					})
			    				}
			    			}
			    	})
			    })
				$('.tablelist tbody tr:odd').addClass('odd');
				$('#replyid').validate({
					answer:{
						rule:{
							required:true
						},
						error:{
							required:'回复内容不能为空'
						},
						message:'请输入回复内容',
						success:'输入正确'
					}
				})
		</script>
		<script>
		</script>
	</body>

</html>